﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
/// <summary>
/// Car_users 的摘要说明
/// </summary>
public class Car_users:SQlHelper
{
	public Car_users()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}
    private string _number;
    private string _name;
    private string _id;
    private string _price;
    private string _old;
    private string _ps;
    private string _state;

    public string number
    {
        get
        {
            return _number;
        }
        set
        {
            _number = value;
        }
    }
    public string name
    {
        get
        {
            return _name;
        }
        set
        {
            _name = value;
        }
    }
    public string id
    {
        get
        {
            return _id;
        }
        set
        {
            _id = value;
        }
    }
    public string price
    {
        get
        {
            return _price;
        }
        set
        {
            _price = value;
        }
    }
    public string old
    {
        get
        {
            return _old;
        }
        set
        {
            _old = value;
        }
    }
    public string ps
    {
        get
        {
            return _ps;
        }
        set
        {
            _ps = value;
        }
    }
    public string state
    {
        get
        {
            return state;
        }
        set
        {
            _state = value;
        }
    }
    //添加一个车主信息
  public int car_users(Car_users tmp)
    {
        string sql = "insert into Car_users(Car_NAME,Car_PASSWORD) values('" + tmp.name + "','" + tmp.ps + "')";
        int result = tmp.ExeNonquery(sql);
        return result;
    }
    //登录车主
    public  int cars(Car_users tmp)
  {
      string sql = "select count(*) from Car_users where Car_NAme='" + tmp.name + "'and Car_PASSWORD='" + tmp.ps + "'";
      int result = tmp.ExeScalar(sql);
      return result;
  }
    //更新车主信息
    public int updateusers(Car_users tmp)
    {
        string sql = "update Car_users set Car_NUMBER='" + tmp.number +
               "', Car_OID= '" + tmp.old+
               "', Car_PRICE= '" + tmp.price +
               "' where Car_ID = '" + tmp.id + "'";
        int result = tmp.ExeNonquery(sql);
        return result;
    }
    public int udate(Car_users tmp)
    {
        string sql = "update Car_users set Car_STATE='" + tmp.state + "' where (Car_ID='" + tmp.id + "' and Car_PASSWORD='" + tmp.ps + "')";
        int x = tmp.ExeNonquery(sql);
        return x;
    }
    public DataSet getallusers()
    {
        Car_users tmp = new Car_users();
        string sql = "select * from Car_users";
        DataSet ds = tmp.GetDs(sql);
        return ds;
    }
    //删除车主信息
    public int delete(Car_users tmp)
    {
        string sql = "delete from Car_users where Car_NUMBER='" + tmp.number + "'";
        tmp.ExeNonquery(sql);
        int result = 0;
        return result;
    }
}